<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增患者药品关联')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-medicine-add">
            <input id="registeredId" name="registeredId" th:value="${registeredId}" type="hidden"/>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">药品ID：</label>
                <div class="col-sm-8">
                    <input id="medicationId" name="medicationId" type="hidden"/>
                    <div class="input-group">
                        <input class="form-control" type="text" onclick="selectMedicationIdRadio()" id="medicationName"
                               readonly="true" th:value="${medicationName}" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">数量：</label>
                <div class="col-sm-8">
                    <input name="quantity" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "hospital/medicine"
        var medicationPrex = ctx+ "hospital/medication";
        $("#form-medicine-add").validate({
            focusCleanup: true
        });


        function selectMedicationIdRadio(){
            var options = {
                title: '选择药品',
                width: "900",
                height: "320",
                url: medicationPrex+"/selectMedication",
                callBack: doMedicationSubmit
            };
            $.modal.openOptions(options);
        }

        function doMedicationSubmit(index,layer){
            var body = $.modal.getChildFrame(index);
            $("#medicationId").val(body.find("#medicationId").val());
            $("#medicationName").val(body.find("#medicationName").val());
            $.modal.close(index);
        }

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-medicine-add').serialize());
            }
        }
    </script>
</body>
</html>